package jxl;

import com.github.stuxuhai.jpinyin.PinyinFormat;
import com.github.stuxuhai.jpinyin.PinyinHelper;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import java.io.File;

public class PinYin {
    public static void main(String args[]) throws Exception{
        //String excelPath = "C:\\Users\\lichujun\\Desktop\\上海\\税管员\\1-9税务所.xls";
        String excelPath = "C:\\Users\\lichujun\\Desktop\\上海\\税管员\\10-20税务所.xls";
        Workbook wb = Workbook.getWorkbook(new File(excelPath));
        //打开一个文本的副本，并指定数据写回到源文件
        WritableWorkbook book = Workbook.createWorkbook(new File(excelPath),wb);
        WritableSheet sheet  = book.getSheet(0);
        int totalRows = sheet.getRows();
        for(int i = 0; i < totalRows; i++){
            String company = sheet.getCell(5, i).getContents().trim();
            Label label = new Label(7, i, PinyinHelper.convertToPinyinString(
                    company,"", PinyinFormat.WITHOUT_TONE));
            sheet.addCell(label);
        }
        book.write();
        book.close();
    }
}
